  <%@ page language='java' contentType='text/html; charset=UTF-8'
    pageEncoding='UTF-8'%>
    <%@ taglib prefix='fmt' uri='http://java.sun.com/jsp/jstl/fmt' %>
    <%@ taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core'%>
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript' src='jquery-1.7.2.js'></script>
<script type='text/javascript'>
	// 시간출력시 두자리 표현 ex) 5 -> 05
	function Round(n, pos) {
		var digits = Math.pow(10, pos);
		var sign = 1;
		if (n < 0) {
			sign = -1;
		}
		n = n * sign;
		var num = Math.round(n * digits) / digits;
		num = num * sign;
		return num.toFixed(pos);
	}
	$(document).ready(function() {
		$(".title").hover(function(){
			$("#fmbA").trigger("click");
		});
		now = new Date();	year = now.getFullYear();	month = now.getMonth() + 1;	date = now.getDate();	hour = now.getHours();	min = now.getMinutes();	sec = now.getSeconds();
		var current;
		if(hour>=12){
			current ="PM";
			hour = now.getHours()-12;
		}else{
			current ="AM";
		}
		$(".fmbdate").text(strFormat(year)+"/"+strFormat(month)+"/"+strFormat(date));
		$(".fmbtime").text(current+" "+strFormat(hour)+":"+strFormat(min)+":"+strFormat(sec));
		// 실시간 DashBoard 출력 Ajax  trigger 을 통한 자동 이벤트 발생
		$("#fmbA").trigger("click");
		$('#fmbA').click(function(){
			$.ajax({
				url:'spc.do?command=recycleMain',
				dataType:'json',
				success : function(js){
					now = new Date();	year = now.getFullYear();	month = now.getMonth() + 1;	date = now.getDate();	hour = now.getHours();	min = now.getMinutes();	sec = now.getSeconds();
					var current;
					if(hour>=12){
						current ="PM";
						hour = now.getHours()-12;
					}else{
						current ="AM";
					}
					fmbtable="<table border='1' cellspacing='0' width='800px' height='150px' ><tr><td rowspan='3' width='20%'>";
					fmbtable+="<table style='border-collapse: collapse; border: 1px solid #f5f5f5;'  border='1' cellspacing='0' width='160px' height='150px'><tr><td  style='font-size: 28px'>"+strFormat(year)+"/"+strFormat(month)+"/"+strFormat(date)+"</td></tr><tr><td style='font-size: 27px'>"+current+" "+strFormat(hour)+":"+strFormat(min)+":"+strFormat(sec)+"</td></tr></table>";
					fmbtable+="</td><td width='20%'><font size='4'><b>목표량</b></td><td width='25%' align='right' style='text-align: right'><font size='6'>1000&nbsp;&nbsp;EA&nbsp;</td>";
					fmbtable+="<td rowspan='3' width='15%'><font size='4'><b>불량률</td><td rowspan='3' width='20%'><font size='6'>";
					if(js.map.RealTQOk==0){
						fmbtable+="0";	
					}else{
						fmbtable+=Round(js.map.RealTQNo/(js.map.RealTQOk+js.map.RealTQNo)*100,2);	
					}
					fmbtable+="&nbsp;%</td></tr>	<tr><td ><font size='4'><b>생산량</td><td style='text-align: right'><font size='6'>"+js.map.RealTQOk+"&nbsp;&nbsp;EA&nbsp;</td></tr><tr>";
					fmbtable+="<td><font size='4'><b>달성률</td><td style='text-align: right'><font size='6'>";
					if(js.map.RealTQOk==0){
						fmbtable+="0";	
					}else{
						fmbtable+=Round(js.map.RealTQOk/1000*100,2);	
					}
					fmbtable+="&nbsp;&nbsp;&nbsp;%&nbsp;&nbsp;</td></tr></table><br><p class='title'>Product Status </p>";
					fmbtable += "<table border='1' cellspacing='0' width='800px'>	<tr><td rowspan='2' width='10%'>Type</td><td colspan='4' width='45%'>Every Day</td><td colspan='4'>Today</td></tr>	<tr><td width='10%'>총계</td><td width='10%'>수행</td><td width='10%'>미수행</td><td width='10%'>달성률</td><td width='10%'>총계</td><td width='10%'>수행</td><td width='10%'>미수행</td><td width='10%'>달성률</td></tr><tr><td>WorkOrder</td><td>${requestScope.map.EOTotal }</td><td><font color='blue'>${requestScope.map.EOOk }</font></td><td><font color='red'>"+js.map.EONo+"</font></td><td>";
					if(js.map.EOTotal==0){
						fmbtable+="0&nbsp;";	
					}else{
						fmbtable+=Round(js.map.EOOk/js.map.EOTotal*100,2);	
					}
					fmbtable+="%</td><td>"+js.map.TOTotal +"</td><td><font color='blue'>"+js.map.TOOk +"</font></td><td><font color='red'>"+js.map.TONo+"</font></td><td>";
					if(js.map.TOTotal ==0){
					fmbtable+="0&nbsp;";	
					}else{
						fmbtable+=Round(js.map.TOOk/js.map.TOTotal*100, 2);	
					}
					fmbtable+="%</td></tr><tr><td>Quantity</td><td>"+js.map.EQTotal +"</td><td><font color='blue'>"+js.map.EQOk+"</font></td><td><font color='red'>"+js.map.EQNo+"</font></td><td>";
					if(js.map.EQTotal==0 ){
						fmbtable+="0&nbsp;";	
					}else{
						fmbtable+=Round(js.map.EQOk/js.map.EQTotal*100, 2);
					}
					fmbtable+="%</td><td>"+js.map.TQTotal+"</td><td><font color='blue'>"+js.map.TQOk+"</font></td><td><font color='red'>"+js.map.TQNo+"</font></td><td>";
				if(js.map.TQTotal==0){
						fmbtable+="0&nbsp;";	
					}else{
						fmbtable+= Round(js.map.TQOk/js.map.TQTotal*100,2); 
					}
					fmbtable+="%</td></tr>	</table><br>";
					fmbtable+="<p class='title'>Defect Status</p><table border='1' cellspacing='0' width='800px'><tr><td rowspan='2' width='10%'>Station</td><td colspan='4' width='45%'>Every day</td><td colspan='4'>Today</td></tr><tr>";
					fmbtable+="<td width='10%'>총계</td><td width='10%'>완제품</td><td width='10%'>불량품</td><td width='10%'>불량률</td><td width='10%'>총계</td><td width='10%'>완제품</td><td width='10%'>불량</td><td width='10%'>불량률</td>";
					fmbtable+="</tr><tr><td>1공정</td><td>"+js.map.ES1Total+"</td><td><font color='blue'>"+js.map.ES1Ok+"</font></td><td><font color='red'>"+js.map.ES1Fail+"</font></td><td>";
					if(js.map.ES1Total==0){
						fmbtable+="0&nbsp;";	
					}else{
						fmbtable+=Round(js.map.ES1Fail/js.map.ES1Total*100,2);
					}
					fmbtable+="%</td>";
					fmbtable+="<td>"+js.map.TS1Total+"</td><td><font color='blue'>"+js.map.TS1Ok+"</font></td><td><font color='red'>"+js.map.TS1Fail+"</font></td><td>";
					if(js.map.TS1Total==0){
						fmbtable+="0&nbsp;";	
					}else{
						fmbtable+=Round(js.map.TS1Fail/js.map.TS1Total*100,2);
					}
					fmbtable+="%</td></tr><tr><td>2공정</td><td>"+js.map.ES2Total+"</td><td><font color='blue'>"+js.map.ES2Ok+"</font></td><td><font color='red'>"+js.map.ES2Fail+"</font></td><td>";
					if(js.map.ES2Total==0){
						fmbtable+="0&nbsp;";	
					}else{
						fmbtable+=Round(js.map.ES2Fail/js.map.ES2Total*100,2);
					}
					fmbtable+="%</td><td>"+js.map.TS2Total+"</td><td><font color='blue'>"+js.map.TS2Ok+"</font></td><td><font color='red'>"+js.map.TS2Fail+"</font></td><td>";
					if(js.map.TS2Total==0){
						fmbtable+="0&nbsp;";	
					}else{
						fmbtable+=Round(js.map.TS2Fail/js.map.TS2Total*100,2);
					}
					fmbtable+="%</td></tr><tr><td>3공정</td><td>"+js.map.ES3Total+"</td><td><font color='blue'>"+js.map.ES3Ok+"</font></td><td><font color='red'>"+js.map.ES3Fail+"</font></td><td>";
					if(js.map.ES3Total==0){
						fmbtable+="0&nbsp;";	
					}else{
						fmbtable+=Round(js.map.ES3Fail/js.map.ES3Total*100,2);
					}
					fmbtable+="%</td><td>"+js.map.TS3Total+"</td><td><font color='blue'>"+js.map.TS3Ok+"</font></td><td><font color='red'>"+js.map.TS3Fail+"</font></td><td>";
					if(js.map.TS3Total==0){
						fmbtable+="0&nbsp;";	
					}else{
						fmbtable+=Round(js.map.TS3Fail/js.map.TS3Total*100,2);
					}
					fmbtable+="%</td></tr><tr><td>4공정</td><td>"+js.map.ES4Total+"</td><td><font color='blue'>"+js.map.ES4Ok+"</font></td><td><font color='red'>"+js.map.ES4Fail+"</font></td><td>";
					if(js.map.ES4Total==0){
						fmbtable+="0&nbsp;";	
					}else{
						fmbtable+=Round(js.map.ES4Fail/js.map.ES4Total*100,2);
					}
					fmbtable+="%</td><td>"+js.map.TS4Total+"</td><td><font color='blue'>"+js.map.TS4Ok+"</font></td><td><font color='red'>"+js.map.TS4Fail+"</font></td><td>";
					if(js.map.TS4Total==0){
						fmbtable+="0&nbsp;";	
					}else{
						fmbtable+=Round(js.map.TS4Fail/js.map.TS4Total*100,2);
					}
					fmbtable+="%</td></tr>	</table>";
					$("#fmbPage").html(fmbtable);
					$("#fmbA").trigger("click");
				}
			}); // reflashBtn ajax
		}); // reflashBtn click
	}); // ready
	function strFormat(str){
		if((str+"").length == 1) str = "0" + str;
		return str;				
	}
</script>
<p class='title'><b>Dash Board </b></p><p align="right" style="margin-right: 50px">기준 : 일 </p>	
<div id='fmbPage'>
<table border='1' cellspacing='0' width='800px' height="150px" class="a">
<tr bgcolor="red">
	<td rowspan="3" width="20%">
		<table style="border-collapse: collapse; border: 1px solid #f5f5f5;"  border='1' cellspacing='0' width='160px' height="150px"><tr><td class='fmbdate' style="font-size: 28px"></td></tr><tr><td class='fmbtime' style="font-size: 27px"></td></tr></table>
	</td>
	<td width="20%"><font size='4'><b>목표량</b></td><td width="25%" align="right" style='text-align: right'><font size='6'>1000&nbsp;&nbsp;EA&nbsp;</td>
	<td rowspan="3" width="15%"><font size='4'><b>불량률</td>
	<td rowspan="3" width="20%"><font size='6'><c:if test='${requestScope.map.RealTQOk ==0}'>0</c:if><c:if test='${requestScope.map.RealTQOk!=0 }'><fmt:formatNumber value='${requestScope.map.RealTQNo/(requestScope.map.RealTQOk+requestScope.map.RealTQNo)*100 }' maxFractionDigits='2' minFractionDigits='2' /></c:if>&nbsp;%</td>
</tr>
<tr>
	<td ><font size='4'><b>생산량</td><td style='text-align: right'><font size='6'>${requestScope.map.RealTQOk }&nbsp;&nbsp;EA&nbsp;</td>
	
</tr>
<tr>
	<td><font size='4'><b>달성률</td>
	<td style='text-align: right'><font size='6'><c:if test='${requestScope.map.RealTQOk ==0}'>0</c:if><c:if test='${requestScope.map.RealTQOk!=0 }'><fmt:formatNumber value='${requestScope.map.RealTQOk/1000*100 }' maxFractionDigits='2' minFractionDigits='2' /></c:if>&nbsp;&nbsp;&nbsp;%&nbsp;&nbsp;</td>
</tr>
</table><br>
<p class='title'>Product Status </p>
<table border='1' cellspacing='0' width='800px'>
	<tr>
		<td rowspan='2' width='10%'>Type</td><td colspan='4' width='45%'>Every Day</td><td colspan='4'>Today</td>
	</tr>
	<tr>
		<td width='10%'>총계</td><td width='10%'>수행</td><td width='10%'>미수행</td><td width='10%'>달성률</td>
		<td width='10%'>총계</td><td width='10%'>수행</td><td width='10%'>미수행</td><td width='10%'>달성률</td>
	</tr>
	<tr>
		<td>WorkOrder</td><td>${requestScope.map.EOTotal }</td><td><font color='blue'>${requestScope.map.EOOk }</font></td><td><font color='red'>${requestScope.map.EONo }</font></td>
		<td><c:if test='${requestScope.map.EOTotal  ==0}'>0</c:if>
		<c:if test='${requestScope.map.EOTotal  !=0}'><fmt:formatNumber value='${requestScope.map.EOOk/requestScope.map.EOTotal*100 }' maxFractionDigits='2' minFractionDigits='2'  /></c:if>%</td>
		<td>${requestScope.map.TOTotal }</td><td><font color='blue'>${requestScope.map.TOOk }</font></td><td><font color='red'>${requestScope.map.TONo }</font></td>
		<td><c:if test='${requestScope.map.TOTotal ==0}'>0</c:if>
		<c:if test='${requestScope.map.TOTotal!=0 }'><fmt:formatNumber value='${requestScope.map.TOOk/requestScope.map.TOTotal*100 }' maxFractionDigits='2' minFractionDigits='2' /></c:if>%</td>
	</tr>
		<tr>
		<td>Quantity</td><td>${requestScope.map.EQTotal }</td><td><font color='blue'>${requestScope.map.EQOk }</font></td><td><font color='red'>${requestScope.map.EQNo }</font></td>
		<td><c:if test='${requestScope.map.EQTotal==0 }'>0</c:if>
		<c:if test='${requestScope.map.EQTotal!=0 }'><fmt:formatNumber value='${requestScope.map.EQOk/requestScope.map.EQTotal*100 }' maxFractionDigits='2'  minFractionDigits='2'/></c:if>%</td>
		<td>${requestScope.map.TQTotal }</td><td><font color='blue'>${requestScope.map.TQOk }</font></td><td><font color='red'>${requestScope.map.TQNo }</font></td>
		<td><c:if test='${requestScope.map.TQTotal==0 }'>0</c:if>
		<c:if test='${requestScope.map.TQTotal!=0 }'><fmt:formatNumber value='${requestScope.map.TQOk/requestScope.map.TQTotal*100 }' maxFractionDigits='2' minFractionDigits='2' /></c:if>%</td>
	</tr>
	</table><br>
	<p class='title'>Defect Status</p>
	<table border='1' cellspacing='0' width='800px'>
	<tr>
<td rowspan='2' width='10%'>Station</td><td colspan='4' width='45%'>Every day</td><td colspan='4'>Today</td>
</tr>
		<tr>
	<td width='10%'>총계</td><td width='10%'>완제품</td><td width='10%'>불량품</td><td width='10%'>불량률</td><td width='10%'>총계</td><td width='10%'>완제품</td><td width='10%'>불량</td><td width='10%'>불량률</td>
	</tr>
		<tr>
			<td>1공정</td><td>${requestScope.map.ES1Total }</td><td><font color='blue'>${requestScope.map.ES1Ok}</font></td><td><font color='red'>${requestScope.map.ES1Fail}</font></td>
			<td><c:if test='${requestScope.map.ES1Total==0 }'>0</c:if>
			<c:if test='${requestScope.map.ES1Total!=0 }'><fmt:formatNumber value='${requestScope.map.ES1Fail/requestScope.map.ES1Total*100 }' maxFractionDigits='2' minFractionDigits='2'/></c:if>%</td>
			<td>${requestScope.map.TS1Total }</td><td><font color='blue'>${requestScope.map.TS1Ok}</font></td><td><font color='red'>${requestScope.map.TS1Fail}</font></td>
			<td><c:if test='${requestScope.map.TS1Total==0 }'>0</c:if>
			<c:if test='${requestScope.map.TS1Total!=0 }'><fmt:formatNumber value='${requestScope.map.TS1Fail/requestScope.map.TS1Total*100 }' maxFractionDigits='2' minFractionDigits='2' /></c:if>%</td>
		</tr>
		<tr>
			<td>2공정</td><td>${requestScope.map.ES2Total }</td><td><font color='blue'>${requestScope.map.ES2Ok}</font></td><td><font color='red'>${requestScope.map.ES2Fail}</font></td>
			<td><c:if test='${requestScope.map.ES2Total==0 }'>0</c:if>
			<c:if test='${requestScope.map.ES2Total!=0 }'><fmt:formatNumber value='${requestScope.map.ES2Fail/requestScope.map.ES2Total*100 }' maxFractionDigits='2'  minFractionDigits='2'/></c:if>%</td>
			<td>${requestScope.map.TS2Total }</td><td><font color='blue'>${requestScope.map.TS2Ok}</font></td><td><font color='red'>${requestScope.map.TS2Fail}</font></td>
			<td><c:if test='${requestScope.map.TS2Total==0 }'>0</c:if>
			<c:if test='${requestScope.map.TS2Total!=0 }'><fmt:formatNumber value='${requestScope.map.TS2Fail/requestScope.map.TS2Total*100 }' maxFractionDigits='2'  minFractionDigits='2'/></c:if>%</td>
		</tr>
		<tr>
			<td>3공정</td><td>${requestScope.map.ES3Total }</td><td><font color='blue'>${requestScope.map.ES3Ok}</font></td><td><font color='red'>${requestScope.map.ES3Fail}</font></td>
			<td><c:if test='${requestScope.map.ES3Total==0 }'>0</c:if>
			<c:if test='${requestScope.map.ES3Total!=0 }'><fmt:formatNumber value='${requestScope.map.ES3Fail/requestScope.map.ES3Total*100 }' maxFractionDigits='2' minFractionDigits='2' /></c:if>%</td>
			<td>${requestScope.map.TS3Total }</td><td><font color='blue'>${requestScope.map.TS3Ok}</font></td><td><font color='red'>${requestScope.map.TS3Fail}</font></td>
			<td><c:if test='${requestScope.map.TS3Total==0 }'>0</c:if>
			<c:if test='${requestScope.map.TS3Total!=0 }'><fmt:formatNumber value='${requestScope.map.TS3Fail/requestScope.map.TS3Total*100 }' maxFractionDigits='2' minFractionDigits='2'  /></c:if>%</td>
		</tr>
		<tr>
			<td>4공정</td><td>${requestScope.map.ES4Total }</td><td><font color='blue'>${requestScope.map.ES4Ok}</font></td><td><font color='red'>${requestScope.map.ES4Fail}</font></td>
			<td><c:if test='${requestScope.map.ES4Total==0 }'>0</c:if>
			<c:if test='${requestScope.map.ES4Total!=0 }'><fmt:formatNumber value='${requestScope.map.ES4Fail/requestScope.map.ES4Total*100 }' maxFractionDigits='2' minFractionDigits='2' /></c:if>%</td>
			<td>${requestScope.map.TS4Total }</td><td><font color='blue'>${requestScope.map.TS4Ok}</font></td><td><font color='red'>${requestScope.map.TS4Fail}</font></td>
			<td><c:if test='${requestScope.map.TS4Total==0 }'>0</c:if>
			<c:if test='${requestScope.map.TS4Total!=0 }'><fmt:formatNumber value='${requestScope.map.TS4Fail/requestScope.map.TS4Total*100 }' maxFractionDigits='2' minFractionDigits='2' /></c:if>%</td>
		</tr>
	</table>
	</div>
<a href="#" id='fmbA' ></a>